|
|
|
|
|
|
|
First add another label and a drop-down combo box control to the form. Set the label caption to Customer Type, and set the drop-down combo box Name property to cboCustType and the Style property to 2DropDown List. Your form should look like the one in Figure 5.7. |
|
|
|
|
|
|
|
|
Figure 5.7.
Adding the DropDown
List control to the form. |
|
|
|
|
| |
|
|
|
|
You can't change the height of the combo box control in Visual Basic 5. It is set at 315 twips and cannot be updated. |
|
|
|
|
|
|
|
|
|
|
Now add Listing 5.5 to load the list box with valid values. |
|
|
|
|
|
|
|
|
Listing 5.5. The Form_Load event to load a list box. |
|
|
|
|
|
|
|
|
Sub Form_Load ()
'
' load dropdown list box
cboCustType.AddItem "Retail"
cboCustType.AddItem "Wholesale"
cboCustType.AddItem "Distributor"
cboCustType.AddItem "Other"
End Sub |
|
|
|
|
|
|
|
|
In Listing 5.5, you are adding values directly to the list using program code. Each AddItem method adds an additional valid selection to the list. You could also load the control with values from a data table. This would give you a more dynamic list of valid values. For now, stick to the direct load example here; later in this book, you add validation lists loaded from data tables. |
|
|
|
|
|
|
|
|
Now save and run the program. You can now click the down arrow of the drop-down list box and see the list of valid values. Now the user can't help but pick a correct item for the input field. |
|
|
|
|
|